import service.LoadBalance;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * @author chaird
 * @create 2023-05-28 23:39
 */
public class App {
    public static void main(String[] args) {
        ServiceLoader<LoadBalance> loadBalanceServiceLoader = ServiceLoader.load(LoadBalance.class);
        Iterator<LoadBalance> iterator = loadBalanceServiceLoader.iterator();
        while (iterator.hasNext()) {
            LoadBalance loadBalance = iterator.next();
            System.out.println("获取到负载均衡策略:" + loadBalance);
            System.out.println(loadBalance.random());
        }
    }
}
